package com.edu.juc.bean;

import lombok.Data;

import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.LongAccumulator;
import java.util.concurrent.atomic.LongAdder;

@Data
public class ClickNumber {
    private long number;

    public synchronized void increaseSynchronized() {
        number++;
    }

    AtomicLong atomicLong = new AtomicLong(0);

    public void increaseAtomicLong() {
        atomicLong.getAndIncrement();
    }

    LongAdder longAdder = new LongAdder();

    public void increaseLongAdder() {
        longAdder.increment();
    }

    LongAccumulator longAccumulator = new LongAccumulator(Long::sum, 0);

    public void increaseLongAccumulator() {
        longAccumulator.accumulate(1);
    }

    public long get() {
        return number;
    }
}
